<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>
<%@ page isELIgnored="true" %>
<%@ page import = "java.util.*" %>
<jsp:useBean id="user" scope="session" class="worklog.db.UserDB"/>
<%
	Object statusO = session.getAttribute("status");
	if (statusO == null || (Integer) statusO < 2) response.sendRedirect("index.jsp");
%>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Worklog3</title>
<link rel="stylesheet" type="text/css" href="themes/aristo/jquery-ui-1.8.7.custom.css">
<link rel="stylesheet" type="text/css" href="css/widgets.css">
<link rel="stylesheet" type="text/css" href="css/main.css">
<link rel="stylesheet" type="text/css" href="css/admin.css">
</head>
<body class="admin">
	<jsp:include page = "menu.jsp" />

	<section id="wrapper">
		<div class="admin-pane">
			<header class="admin-pane-header">Projects</header>
			<table id="projectsList" class="admin-table">
				<thead><tr><td>ID</td><td>Name</td><td>Archive</td><td>Entries</td><td class="actions"></td></tr></thead>
				<tfoot><tr class="row" data-type="project">
					<td>New:</td>
					<td><input type="text" name="name" /></td>
					<td><label><input type="checkbox" name="archive" value="true" /> archive</label></td>
					<td></td>
					<td class="actions"><div data-action="save" title="Add" class="icon icon-save">Add</div></td>
				</tr></tfoot>
				<tbody></tbody>
			</table>
		</div>
		<div class="admin-pane">
			<header class="admin-pane-header">Users</header>
			<table id="usersList" class="admin-table">
				<thead><tr><td>ID</td><td>Login</td><td>Email</td><td>Status</td><td class="action"></td></tr></thead>
				<tfoot><tr class="row" data-type="user">
					<td>New:</td>
					<td><input type="text" name="login" /></td>
					<td><input type="text" name="email" /></td>
					<td><select name="status"><option value="0">-</option><option value="1">user</option><option value="2">admin</option></select></td>
					<td class="actions"><div data-action="save" title="Add" class="icon icon-save">Add</div></td>
				</tr></tfoot>
				<tbody></tbody>
			</table>
		</div>
	</section>


<script id="projectTemplate" type="text/x-jquery-tmpl">
<tr class="row {{if archive==true}}is-archived{{/if}}" data-id="${id}" data-type="project">
	<td>${id}</td>
	<td class="td-name">${name}</td>
	<td>{{if archive==true}}Yes{{/if}}</td>
	<td>${entries}</td>
	<td class="actions"><div data-action="delete" title="Delete" class="icon icon-delete"></div></td>
</tr>
</script>
<script id="projectEditTemplate" type="text/x-jquery-tmpl">
<tr class="row in-edit" data-id="${id}" data-type="project">
	<td>${id}</td>
	<td><input type="text" name="name" value="${name}"/></td>
	<td><label><input type="checkbox" name="archive" value="true" {{if archive==true}} checked="checked"{{/if}}/> archive</label></td>
	<td></td>
	<td class="actions"><div data-action="save" title="Save" class="icon icon-save"></div><div data-action="cancel" title="Cancel" class="icon icon-cancel"></div></td>
</tr>
</script>


<script id="userTemplate" type="text/x-jquery-tmpl">
<tr class="row" data-id="${id}" data-type="user">
	<td>${id}</td>
	<td class="td-name">${login}</td>
	<td>${email}</td>
	<td>{{if status==2}}admin{{else}}user{{/if}}</td>
	<td class="actions">
		<div data-action="delete" title="Delete" class="icon icon-delete"></div>
		<div data-action="resetpass" title="Reset password" class="icon icon-resetpass"></div>
	</td>
</tr></script>
<script id="userEditTemplate" type="text/x-jquery-tmpl">
<tr class="row in-edit" data-id="${id}" data-type="user">
	<td>${id}</td>
	<td><input type="text" name="login" value="${login}"/></td>
	<td><input type="text" name="email" value="${email}"/></td>
	<td><select name="status"><option value="0">-</option>
		<option value="1" {{if status==1}} selected="selected"{{/if}}>user</option>
		<option value="2" {{if status==2}} selected="selected"{{/if}}>admin</option>
	</select></td>
	<td class="actions">
		<div data-action="save" title="Save" class="icon icon-save"></div>
		<div data-action="cancel" title="Cancel" class="icon icon-cancel"></div>
	</td>
</tr>
</script>



<script src="js/jquery/jquery-1.7.2.min.js"></script>
<script src="js/jquery/jquery-ui-1.8.14.custom.min.js"></script>
<script src="js/jquery/jquery.tmpl.min.js"></script>
<script src="js/jquery/jquery.plugins.js"></script>

<script src="js/_toolbox.js"></script>
<script src="js/widgets/mask.js"></script>
<script src="js/widgets/toaster.js"></script>
<script src="js/widgets/window.js"></script>
<script src="js/components/login.js"></script>
<script>App.User=<%
Object userO = session.getAttribute("userId");
if (userO != null) out.print(user.getUserById((Integer)userO).toString()); else out.print("{}");
%>;</script>
<script src="js/common.js"></script>
<script src="js/admin.js"></script>
</body>
</html>